	
	//到第N页
	function history_topage(page){
		$("#thisPage").val(page);
		var goodsId=$("#goodsId").val();
		$("#goodsOrderHistory").remove();
		$("#loadHistory").show();
		$.post("/browse/ajaxQueryGoodsHistory",{goodsId:goodsId,page:page},function(data){
			rebuildHistoryPage(data.thisPage,data.maxPage);
			setHistory(data)
			},"json");
	}
	
	//跳转至第N页
	function history_turnpage(){
		var page=$("#history_pagenum").val();
		$("#thisPage").val(page);
		var goodsId=$("#goodsId").val();
		$("#goodsOrderHistory").remove();
		$("#loadHistory").show();
		$.post("/browse/ajaxQueryGoodsHistory",{goodsId:goodsId,page:page},function(data){
			rebuildHistoryPage(data.thisPage,data.maxPage);
			setHistory(data)
			},"json");
	}

function rebuildHistoryPage(thisPage,maxPage){
	var pageHTML="";
	if(thisPage>=2){pageHTML+="<a href='javascript:history_topage("+(thisPage-1)+")'> < </a>"}
	else{pageHTML+="<a href='#'> < </a>"}
	if((maxPage-thisPage)>=5){pageHTML+="<span class='now'>"+thisPage+"</span><a href='javascript:history_topage("+(thisPage+1)+")'>"+(thisPage+1)+"</a><a href='javascript:history_topage("+(thisPage+2)+")'>"+(thisPage+2)+"</a><span>…</span><a href='javascript:history_topage("+maxPage+")'>"+maxPage+"</a>"}
	else{
		for(var i=4;i>=0;i--){
			if(maxPage-i==thisPage){pageHTML+="<span class='now'>"+(maxPage-i)+"</span>"}
			else if(maxPage-i>0){pageHTML+="<a href='javascript:history_topage("+(maxPage-i)+")'>"+(maxPage-i)+"</a>"}
		}
	if(maxPage<=thisPage){pageHTML+="<a href='#'> > </a>"}
	else{pageHTML+="<a href='javascript:history_topage("+(thisPage+1)+")'> > </a>"}
	pageHTML+="<font>共"+maxPage+"页</font><form><label>到第</label><input type='text' class='tet' id='history_pagenum' value=''/><input type='button' value='确定'class='sub' onclick='history_turnpage()' id="+maxPage+"/></form>"
		}
	$("div.history_pages").html(pageHTML);
	}
	function setHistory(data){
		var historyStr="<div id='goodsOrderHistory'>";
		for(var i=0;i<data.historyList.length;i++){
			historyStr=historyStr+"<li><span>"+data.historyList[i].buyerName+"</span><span>"+data.historyList[i].goodsName+"</span><span>"
						+data.historyList[i].parseToYuan+"</span><span class='mon'>"+parseToYuan(data.historyList[i].price)+"</span><span>"
						+data.historyList[i].sum+"</span><span>"+parseData(data.historyList[i].createDate)+"</span></li>";
		}
		historyStr+="</div>";
		$("#loadHistory").hide();
		$("#loadHistory").after(historyStr);
		}
	function parsePhone(phone){
		var str=phone.substring(3,4);
		return phone.replace("str","****");
		
		}
	function parseData(date){
		var localDate=new Date(date);
		return (localDate.getFullYear()+"-"+localDate.getMonth()+"-"+localDate.getDate()+" "+localDate.getHours()+":"+localDate.getMinutes()+":"+localDate.getSeconds())
	}
	
